﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Reflection;
using System.Configuration;
using System.Xml;

namespace WSI.SitesInteractor
{
    public class AppConfigurationHelper : Dictionary<string, string>
    {
        // We are interested in the executing assembly, not the calling assembly since this class will be used by another class in this helper helper assembly
        public AppConfigurationHelper(string configFilePath)
        {
            try
            {
                //create a new XML Document 
                XmlDocument doc = new XmlDocument();

                //load an XML document by using the 
                //XMLTextReader class of the XML Namespace 
                //Now open the cfgFile 
                doc.Load(new XmlTextReader(configFilePath));

                //retrieve a list of nodes in the document 
                XmlNode parentNode = doc.SelectSingleNode("//configuration");
                if (parentNode != null)
                {
                    XmlNodeList configNodes = parentNode.ChildNodes;
                    foreach (XmlNode node in configNodes)
                    {
                        this.Add(node.Name, node.InnerText);
                    }
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }

        }

    }

}
